#include <bits/stdc++.h>
using namespace std;
int T;
int main() {
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    cin >> T;
    while(T--) {
        int n, m, L, V;
        cin >> n >> m >> L >> V;
        int x[100005], y[100005];
        memset(x, 0, sizeof(x));
        memset(y, 0, sizeof(y));
        for(int i = 1; i <= n; i++) {
            int d, v, A;
            cin >> d >> v >> A;
            if(v <= V && A <= 0) {
                x[i] = y[i] = -1;
            } else if(v > V && A >= 0) {
                x[i] = d;
                y[i] = L;
            } else if(v <= V && A > 0) {
                double cnt = (V * V - v * v) / (2.0 * A);
                x[i] = d + floor(cnt + 1);
                y[i] = L;
            } else {
                double cnt = (V * V - v * v) / (2.0 * A);
                x[i] = d;
                y[i] = d + ceil(cnt - 1);
            }

        }
        vector<int> a[100005];
        for(int i = 0; i <= 100000; i++) {
            a[i].clear();
        }
        int f[100005];
        memset(f, 0, sizeof(f));
        int ans1 = 0, ans2 = 0;
        for(int i = 1; i <= m; i++) {
            int tmp;
            cin >> tmp;
            for(int j = 1; j <= n; j++) {
                if(x[j] <= tmp && tmp <= y[j]) {
                    if(!f[j]) {
                        ans1++;
                    }
                    f[j]++;
                    a[i].push_back(j);
                }
            }
        }
        for(int i = 1; i <= m; i++) {
            bool flag = false;
            for(int j = 0; j < a[i].size(); j++) {
                if(f[a[i][j]] == 1) {
                    flag = true;
                    break;
                }
            }
            if(!flag) {
                ans2++;
                for(int j = 0; j < a[i].size(); j++) {
                    f[a[i][j]]--;
                }
            }
        }
        cout << ans1 << " " << ans2 << endl;
    }
    return 0;
}

